package com.seanzx.resolver.impl;

import com.seanzx.common.Result;
import com.seanzx.constant.SymbolTable;
import com.seanzx.lexical.Token;
import com.seanzx.resolver.IResolver;
import com.seanzx.dp.ProcessorController;

import java.util.List;

public class DropDatabaseResolver implements IResolver<String> {
    ProcessorController processorController = ProcessorController.get();

    @Override
    public boolean matches(List<Token> tokens) {
        return tokens.size() == 3 &&
                tokens.get(0).getValue().equals(SymbolTable.DROP) &&
                tokens.get(1).getValue().equals("DATABASE");
    }

    @Override
    public String translate(List<Token> tokens) {
        return tokens.get(3).getValue();
    }

    @Override
    public boolean validate(Object parameter) {
        return true;
    }

    @Override
    public Result access(Object parameter) {
        return processorController.dropDatabase((String) parameter);
    }
}
